package org.correct.crawler;

import java.util.LinkedList;

public class DenyDomainFilter implements Filter {
	private LinkedList<String> domain;
	
	public DenyDomainFilter(String domain) {
		this.domain = new LinkedList<String>();
		this.domain.add(domain);
	}
	
	public DenyDomainFilter(String[] domainList) {
		domain = new LinkedList<String>();
		for(int i = 0; i < domainList.length; i++) {
			domain.add(domainList[i]);
		}
	}
	
	public synchronized void addDenyDomain(String url) {
		domain.add(url);
	}
	
	@Override
	public synchronized boolean filter(String url) {
		for(String denyDomain : domain)
			if(url.contains(denyDomain))
				return true;
		return false;
	}

}
